package com.superc.model.intent.formatter;


public class IntervalFormater implements IFormatValue{
		private static final long serialVersionUID = 1L;
		private String intervalName="";
		
		@Override
		public String formatValue(String value) {
			try{
				int data=-1;
				if(value!=null){
					data=Integer.parseInt(value);
				}
				if(data<=0){
					return "ÿ" + intervalName;
				}
				else{
					return data + intervalName;
				}
			}
			catch(Exception e){
				e.printStackTrace();
			}
			return "";
		}
		
		public IntervalFormater(String intervalName){
			this.intervalName=intervalName;
		}

		@Override
		public String formatValues(int[] values) {
			String results="";
			for (int value : values) {
				if(value<=0){
					return "ÿ" + intervalName;
				}
				else{
					results+=value + ",";
				}
					
			}
			if(results.length()==0){
				return "ÿ" + intervalName; 
			}
			else{
				return  results.substring(0,results.length()-1)+intervalName;
			}
		}
	}